const { Server } = require('socket.io');
const io = new Server(process.env.IOSOCKET_PORT, { cors: true })

io.on('connection', socket => {
  console.log('连接成功')
  // receive a message from the client
  socket.on('order-update',  e => {
    console.log('收到新消息',e)
    io.emit('notice-kitchen',e);
  })
  socket.on('disconnecting', () => {
    console.log('用户离开，连接断开')
  })
})

console.log('socket.io 启动成功！')